#pragma once
#include <string>

#include "bondlib.h"

class S_BONDLIB_EXPORT SSCTDTools {
 public:
  static void GetPreDay(int& nYear, int& nMonth, int& nDay);
  static void GetNextDay(int& nYear, int& nMonth, int& nDay);
  static int MonthDays(unsigned short iYear, unsigned short iMonth);
  static bool IsLeapYear(int iYear);

  static int GetWeekDay(int nYear, int nMonth, int nDay);
  static void GetNextTradingDay(time_t& tm,
                                bool bWeekend = false);  // bWeekend为true，则工作日但是是周末的日期不算交易日
                                                         // 例如20160206
  static void GetNextCFFEXTradingDay(
      time_t& tm, bool bWeekend = true);  // 获取CFETX下一个工作日
  static void GetNextTradingDay_SSE(time_t& tm, bool bWeekend = false);

  static void GetPreTradingDay(time_t& tm, bool bWeekend = false);
  static void GetPreCFFEXTradingDay(time_t& tm,
                                    bool bWeekend = true);  // 获取CFETX工作日
  static void GetPreTradingDay_SSE(time_t& tm, bool bWeekend = false);

  /************************************************************************/
  /* 是否为中金所节假日
     nDate = YYYYMMDD
  */
  /************************************************************************/
  static bool IsCFFEXHoliday(int nDate);

 private:
  static void GetPreTradingDay(time_t& tm, const char* cCountry,
                               const char* cMarket, bool bWeekend = false);
  static void GetNextTradingDay(time_t& tm, const char* cCountry,
                                const char* cMarket, bool bWeekend = false);
};
